console.log('Background script loaded!');

// 监听浏览器图标点击事件
chrome.browserAction.onClicked.addListener((tab) => {
    console.log('Browser action clicked!', tab.id);
    
    // 向当前标签页发送消息
    chrome.tabs.sendMessage(tab.id, {
        action: 'toggleSidebar'
    }, (response) => {
        if (chrome.runtime.lastError) {
            console.error('Error:', chrome.runtime.lastError);
            return;
        }
        console.log('Response received:', response);
    });
});